/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fanta.framework.manager;

/**
 *
 * @author alessandro
 */
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
/**
 * This is an Application Scoped bean that holds the JPA
 * EntityManagerFactory.  By making this bean Applciation scoped the
 * EntityManagerFactory resource will be created only once for the application
 * and cached here.
 *
 *@author Gordon Yorke
 */
 public class EMFactoryManager {
    protected static EntityManagerFactory emf;
    /*
     * Lazily acquire the EntityManagerFactory and cache it.
     */
     public static EntityManagerFactory getEntityManagerFactory (){
        if (emf == null){
            emf = Persistence.createEntityManagerFactory("FANTAFrameworkPU", new java.util.HashMap());
        }
        return emf;
    }
}

